﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace TienIch
{
    public partial class frmFTP : FormBase
    {
        public frmFTP()
        {
            InitializeComponent();
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            string filename = Application.StartupPath + "\\hu.hack";

            FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.Write);
            UnicodeEncoding encoding = new UnicodeEncoding();
            byte iLength;

            //Write C1 Information 
            iLength = (byte)encoding.GetByteCount(textBox1.Text);
            stream.WriteByte(iLength);
            stream.Write(encoding.GetBytes(textBox1.Text), 0, (int)iLength);

            //Write C2 Information
            iLength = (byte)encoding.GetByteCount(textBox2.Text);
            stream.WriteByte(iLength);
            stream.Write(encoding.GetBytes(textBox2.Text), 0, (int)iLength);

            //Write C3 Information
            iLength = (byte)encoding.GetByteCount(textBox3.Text);
            stream.WriteByte(iLength);
            stream.Write(encoding.GetBytes(textBox3.Text), 0, (int)iLength);

            //Write so pan=0
            iLength = (byte)encoding.GetByteCount(textBox4.Text);
            stream.WriteByte(iLength);
            stream.Write(encoding.GetBytes(textBox4.Text), 0, (int)iLength);
            stream.Close();
            XtraMessageBox.Show("Thành Công");
        }

        private void frmFTP_Load(object sender, EventArgs e)
        {

        }
    }
}
